<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<html lang="en">

<head>
    <meta charset="utf-8">
    <%@include file="head.jsp"%>
    <title> 登录</title>
    <link href="<%=basePath%>/resources/css/login.css" rel="stylesheet">
    <link href="<%=basePath%>/resources/css/my.css" rel="stylesheet" />
    <script src="https://cdn.dingxiang-inc.com/ctu-group/captcha-ui/index.js"></script>
    <style>
    	.form-control, .single-line{width:100%;}
    </style>
</head>
<body class="signin">
    <div class="signinpanel text-center">
        <div class="row">
        	<div class="col-sm-7">
        		<div class="logopanel m-b">
                   <img src="<%=basePath%>/resources/img/d-logo.png" style="margin-top:100px;width:400px;"/>
                </div>
        	</div>
            <div class="col-sm-5">
                <div class="signin-info">
                    <div class="m-b"></div>
                    <h2>统一认证管理平台</h2>                    
                </div>
                <form method="post" action="index.html" style="width:360px;margin:0 auto;" >
                    <input type="text" class="form-control uname" style="width:300px;" id="username" placeholder="用户名" />
                    <input type="password" class="form-control pword m-b" style="width:300px;" id="password" placeholder="密码" />
                    <input type="hidden" id="token">   
                    <div id="c1"></div>                 
                    <button class="btn btn-success btn-block" style="width:300px;" type="button" onclick="go()">登录</button>
                    <div style="margin-top:5px;"></div><span id="msg" style="color:red;"></span></div>
                </form>
            </div>
        </div>
        <div class="signup-footer" style="text-align:center;">
            <div class="pull-center" >
                &copy; 上海德慧信息技术有限公司版权所有
            </div>
        </div>
    </div>
</body>
<script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
        function go(){
        	var username=$("#username").val();
        	var password=$("#password").val();
        	var token=$("#token").val();
        	$.ajax({  
	            url:		'<%=basePath %>/login',  
	            type:		'POST',  
	            data:		{'username':username,'password':password,'token':token}, 
	            dataType:	'json',  
	            success:	function (result) {  
	            	          if(result.status==0){	            	               
	            	        	 alert("验证通过");	            	        	  
	            	          }else{
	            	        	$("#msg").html(result.msg);
	            	          }
							}
			});
        }
        document.onkeydown=function(event){
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if(e && e.keyCode==13){ 
                 go()
               }                
        }; 
        var myCaptcha = _dx.Captcha(document.getElementById('c1'), {
            appId: '4f4d14125d32b0a55dd92d780b7ad580',
            style: 'inline',
            success: function (token) {
            	$("#token").val(token);
            }
        	
        })
    </script>
</html>
